package hk.edu.polyu.comp.motioncapture.point;

import java.util.Vector;
import java.util.Iterator;
import hk.edu.polyu.comp.motioncapture.collection.Sort;
import hk.edu.polyu.comp.motioncapture.point.Point;

public class Frame {

	private Vector<Point> optiFrame;

	public Frame() {
		optiFrame = new Vector<Point>();
	}

	public Frame(int m, int n) {
		optiFrame = new Vector<Point>(m, n);
	}

	public boolean add(Point pt) {
		return optiFrame.add(pt);
	}

	public Point firstPoint() {
		return optiFrame.firstElement();
	}

	public Point[] getPointArray() {
		return optiFrame.toArray(new Point[0]);
	}

	public Point[] getSortedPointsByX() {
		Point.setCompareBy(Point.COMPARE_BY_X);
		return Sort.bubbleSort(getPointArray()); //Sort.heapSort(getPointArray());
	}

	public Point[] getSortedPointsByY() {
		Point.setCompareBy(Point.COMPARE_BY_Y);
		return Sort.bubbleSort(getPointArray()); //Sort.heapSort(getPointArray());
	}

	public Iterator<Point> iterator() {
		return optiFrame.iterator();
	}

	public Point lastPoint() {
		return optiFrame.lastElement();
	}

	public Point pointAt(int index) {
		return optiFrame.elementAt(index);
	}

	public boolean remove(Point pt) {
		return optiFrame.remove(pt);
	}

	public void removeAll() {
		optiFrame.removeAllElements();
	}

	public int size() {
		return optiFrame.size();
	}

}
